package kassiopeia.commons.model.task;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import kassiopeia.commons.model.Coordinates;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;

@XStreamAlias("plugin")
public class PluginInstance  implements Serializable {

    private static final long serialVersionUID = -3513061217331262215L;

    private String instanceId;

    private Coordinates coordinates;

    @XStreamImplicit(itemFieldName = "parameter")
    private List<ParameterInstance> configuration = new ArrayList<ParameterInstance>();

    public PluginInstance() {}

    public PluginInstance(String instanceId, Coordinates coordinates) {
        setCoordinates(coordinates);
        this.instanceId = instanceId;
    }

    public PluginInstance(String instanceId, String pluginId, String groupId, String version) {
        setCoordinates(new Coordinates(pluginId, groupId, version));
        this.instanceId = instanceId;
    }

    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    public void setCoordinates(Coordinates coordinates) {
        this.coordinates = coordinates;
    }

    public Coordinates getCoordinates() {
        return coordinates;
    }


    public List<ParameterInstance> getConfiguration() {
        return configuration;
    }

    public void setConfiguration(List<ParameterInstance> configuration) {
        this.configuration = configuration;
    }

    @Override
    public String toString() {
        return "[Instance: " + instanceId + " of " + getCoordinates().toString() + "]";
    }

}
